<template>
  <div id="search_container">
    <el-row>
      <el-col :span="12"
        ><div class="grid-content bg-purple">
          <el-input
            v-model="inputObject.userInput"
            :id="inputObject.inputId"
            placeholder="请输入你要查找的关键词"
            type="text"
          ></el-input></div
      ></el-col>
      <el-col :span="4"
        ><div class="grid-content bg-purple-light">
          <el-button id="searchBtn" @click="send" type="primary"
            >search</el-button
          >
        </div></el-col
      >
    </el-row>

    <el-row>
      <el-col :span="4"
        ><div class="grid-content bg-purple">
          <el-input
            v-model="pixelToLngLatObject.x"
            :id="pixelToLngLatObject.pixelX"
            placeholder="请输入你要转换的X坐标"
            type="text"
          ></el-input></div
      ></el-col>
      <el-col :span="4"
        ><div class="grid-content bg-purple-light">
          <el-input
            v-model="pixelToLngLatObject.y"
            :id="pixelToLngLatObject.pixelY"
            placeholder="请输入你要转换的Y坐标"
            type="text"
          ></el-input></div
      ></el-col>
      <el-col :span="4"
        ><div class="grid-content bg-purple">
          <el-button id="searchBtn2" @click="convert" type="primary"
            >坐标转换</el-button
          >
        </div></el-col
      >
    </el-row>
  </div>
</template>

<script>
import bus from '../../EventBus/EventBus.js'
export default {
  data() {
    return {
      inputObject: {
        userInput: '',
        inputId: 'searchInput'
      },
      pixelToLngLatObject: {
        x: 0,
        y: 0,
        inputx: 'pixelX',
        inputy: 'pixelY'
      }
    }
  },
  methods: {
    send() {
      bus.$emit('shareUserInput', this.inputObject)
      console.log(this.inputObject)
    },
    convert() {
      bus.$emit('convertxy', this.pixelToLngLatObject)
    }
  },
  mounted() {
    this.send()
  }
}
</script>

<style lang="less" scoped>
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
</style>
